package com.cloud.service.impl;

import com.cloud.dao.ProjectRepository;
import com.cloud.entity.Project;
import com.cloud.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ProjectServiceImpl implements ProjectService {
    @Autowired
    ProjectRepository projectDao;


    @Override
    public Project getProjectById(Integer user_Id) {
        return projectDao.findProjectByPId(user_Id);
    }

    @Override
    public List<Project> getProjectByName(String p_Title) {
        return projectDao.findProjectByPTitle(p_Title);
    }

    @Override
    public List<Project> allProjects() {
        return projectDao.allProjects();
    }

    @Override
    public Integer deleteProject(Integer p_id) {
        projectDao.deleteById(p_id);
        return 1;
    }

    @Override
    public Project updateProject(Project project) {
        return projectDao.save(project);
    }

    @Override
    public Project addProject(Project project) {
        return projectDao.save(project);
    }
}
